#!/bin/bash
#
# Copyright (c) 2012 - mDroidd (martijn.ruijzendaal@gmail.com)
#
# Please ask permission to use parts of this script
# I will be happy to give you!
#
# Credits go to: tommytomatoe, bash, android, github, DEVs
#

# Attention! Because the source section is device-specific, I made some
# Values here to make it easier for you to edit.
#

	function Source
	{

	if ! [ -d $ScriptDir/WORKING_DIR_$1 ]
	then
		mkdir $ScriptDir/WORKING_DIR_$1
		cd $ScriptDir/WORKING_DIR_$1
	else
		cd $ScriptDir/WORKING_DIR_$1
	fi
	if ! [ -d $ScriptDir/WORKING_DIR_$1/.repo ]
	then
	   if [ "$1" = "1" ]
	   then
	    GBSOURCE
	   fi
	   if [ "$1" = "2" ]
	   then
	    ICSSOURCE
	   fi
	   if [ "$1" = "3" ]
	   then
	    CMSOURCE
	   fi
	   if [ "$1" = "4" ]
	   then
	    OxGBSOURCE
	   fi
	   if [ "$1" = "5" ]
	   then
	    AOKPSOURCE
	   fi
	   if [ "$1" = "6" ]
	   then
	    OxICSSOURCE
	   fi
	   if [ "$1" = "7" ]
	   then
	    MiuiSOURCE
	   fi
	   if [ "$1" = "8" ]
	   then
	    CnaSource
	   fi
	fi
	}

	ICSSOURCE="AOSP source (w/ patches from darkspadez)"

# ^^ Is the value that will be displayed in menu

	function ICSSOURCE
	{
	repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
	repo sync
	cd $SDir/hardware/qcom/display
	git pull git://github.com/darkspadez/android_hardware_qcom_display.git
	echo "add_lunch_combo htc_vision-userdebug" >> $Dir/vendor/android/vendorsetup.sh
	echo "add_lunch_combo htc_vision-eng" >> $Dir/vendor/android/vendorsetup.sh
	}

# ^^ That are the commands that will be executed when option is chosen
# Change the "repo init -u" to the one who ported the ROM to your device or stock

	GBSOURCE="Stock AOSP GB Source (w/o patches)"

	function GBSOURCE
	{
	repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
	repo sync
	}

	CMSOURCE="Official CyanogenMod7 Source"

	function CMSOURCE
	{
	repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
	repo sync
	}

	OxGBSOURCE="Oxygen source (w/o patches)"

	function OxGBSOURCE
	{
	repo init -u git://github.com/oxygen-rom/android_manifest.git -b gingerbread
	repo sync
	}

	AOKPSOURCE="Android Open Kang SOURCE (RomanBB)"

	function AOKPSOURCE
	{
	repo init -u https://github.com/AOKP/platform_manifest.git -b master
	repo sync
	if ! [ -d $SDir/vendor/htc ]
	then
		mkdir $SDir/vendor/htc
		mkdir $SDir/device/htc
	fi
	if ! [ -d $SDir/vendor/htc/* ]
	then
		git clone git://github.com/CyanogenMod/android_device_htc_vision.git -b ics vendor/htc
		git clone github.com/koush/proprietary_vendor_htc.git -b ics device/htc
	fi
	echo "add_lunch_combo htc_vision-userdebug" >> $Dir/vendor/aokp/vendorsetup.sh
	echo "add_lunch_combo htc_vision-eng" >> $Dir/vendor/aokp/vendorsetup.sh
	}

	OxICSSOURCE="[UNAVAILABLE]Oxygen ICS Source"

	function OxICSSOURCE
	{
	#repo init -u
	#repo sync
	clear; echo "Not defined yet!"
	}

	CNASOURCE="[NEW] CodeName Android Source (ICS)"
	function CnaSource
	{
	repo init -u git://github.com/CNA/android_manifest.git -b mod-4.0.3
	repo sync
	echo "add_lunch_combo htc_vision-userdebug" >> $Dir/vendor/android/vendorsetup.sh
	echo "add_lunch_combo htc_vision-eng" >> $Dir/vendor/android/vendorsetup.sh
	}
